﻿using System;
using System.Web;
using System.Xml;
using SyCODE.Component;
using SyCODE.Component.DataFactory;
using System.Data.Common;
using System.Collections.Specialized;
using SyCODE.Component.Cryptography;
using SyCODE.Component.Security;

namespace SyCODE.Blog.Admin
{
    /// <summary>
    /// 后台处理请求基类
    /// </summary>
    public abstract class HandlerBase : IHttpHandler
    {
        protected bool Authenticated = false;
        protected string Account = String.Empty;
        protected byte Level = 0;

        public HandlerBase() 
        {
            Ticket ticket = Ticket.Get("manager");

            if (Ticket.Authenticate(ticket))
            {
                Authenticated = true;
                Account = ticket.Name;
                Level = Byte.Parse(ticket.UserData);
            }
            else 
            {
                Function.ClientAlert(StringResource.GetField("invalidlogin"));
            }
        }

        public virtual bool IsReusable
        {
            get
            {
                return false;
            }
        }

        public abstract void ProcessRequest(HttpContext context);
    }
}
